//
//  FirstCustomeSegueUnwind.swift
//  Transition2
//
//  Created by Open on 2/3/15.
//  Copyright (c) 2015 open-groupe. All rights reserved.
//

import UIKit

class FirstCustomeSegueUnwind: UIStoryboardSegue {

    override func perform() {
        var secondeVCView = self.sourceViewController.view as UIView!
        var firstVCView   = self.destinationViewController.view as UIView!
        
        let screenHeight = UIScreen.mainScreen().bounds.size.height
        
        let window = UIApplication.sharedApplication().keyWindow
        window?.insertSubview(firstVCView, aboveSubview: secondeVCView)
        
        UIView.animateWithDuration(0.4, animations: {() -> Void in
          firstVCView.frame = CGRectOffset(firstVCView.frame, 0, screenHeight)
        secondeVCView.frame = CGRectOffset(secondeVCView.frame, 0, screenHeight)
        })
            { (finished) -> Void in
                    self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)
        }
    }
}
